<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">

<ui:composition template="../templates/popup.xhtml">
	<ui:define name="titre">#{lbl['menu.hub.departure']}</ui:define>
	<ui:define name="popup_page">
		<h:form id="formation_1_plan_form">
			<h:panelGrid id="formation_1_plan_panel">
				<h:panelGroup>
					<h:outputText value="#{lbl['compo.departure.plan.title']}" /> : 
			 		<h:outputText value="#{hubManaged.currentSillon.tcmsTrainId}" />
				</h:panelGroup>

				<h:panelGrid id="message_panel" columns="2" border="0"
					cellpadding="0" cellspacing="0">
					<p />
					<rich:messages />
				</h:panelGrid>

				<a4j:outputPanel id="formation_plan_panel">
					<rich:extendedDataTable id="formation_plan_table"
						style="width:1390px;height:560px;border:none;"
						rowClasses="rich_datagrid_even_line, rich_datagrid_odd_line"
						value="#{hubManaged.hub.lstRails}" var="rail"
						iterationStatusVar="it">

						<f:facet name="noData">
							<h:outputText value="#{msg['msg.info.nodata']}" />
						</f:facet>

						<rich:column width="70px" style="text-align:center;">
							<f:facet name="header">
								<h:outputText value="#{lbl['compo.rail']}" />
							</f:facet>
							<h:panelGrid id="nv_#{rail.id}" columnClasses="_center"
								width="60px" border="0" cellpadding="0" cellspacing="0"
								style="background-color:#{rail.destinationHexColor};"
								styleClass="rich_datagrid_pos_line"
								rendered="#{rail.typeBundle.id==2}">
								<h:outputText value="#{rail.number}" />
							</h:panelGrid>

							<h:outputText value="#{rail.number}"
								rendered="#{rail.typeBundle.id!=2}" />

						</rich:column>

						<rich:column width="100px" style="text-align:left;">
							<f:facet name="header">
								<h:outputText value="#{lbl['compo.destination.label']}" />
							</f:facet>
							<h:outputText value="#{rail.destinationLabel}" />
							<h:outputText value="#{rail.typeBundle.label}"
								rendered="#{rail.typeBundle.id!=2}" />
						</rich:column>

						<rich:column width="70px" style="text-align:center;">
							<f:facet name="header">
								<h:outputText value="#{lbl['sillon.formation.rail']}" />
							</f:facet>
							<h:outputText
								value="#{hubManaged.currentSillon.railFormationExtId}" />
						</rich:column>

						<rich:column width="170px" style="text-align:center;">
							<f:facet name="header">
								<h:outputText value="#{lbl['compo.formation.nb.wagon']}" />
							</f:facet>
							<h:outputText value="#{rail.nbRealPos}"
								rendered="#{rail.nbRealPos == 0}" />

							<h:outputText value="#{rail.nbRealPos}" style="font-weight:bold;"
								rendered="#{rail.nbRealPos > 0}" />
						</rich:column>

						<!-- Colonne pour dépiler l'ensemble des wagons. -->
						<rich:column width="35px" style="text-align:center;">
							<f:facet name="header">
							</f:facet>
							<h:graphicImage value="../../imgs/icons/ico_left_arrow.png"
								rendered="#{rail.nbRealPos > 0}"
								onclick="pw_l(#{rail.nbRealPos},'formation_1_plan_form:formation_plan_table:#{it.index}:nbWagonsStack');" />
						</rich:column>

						<rich:column width="170px" style="text-align:center;">
							<f:facet name="header">
								<h:outputText value="#{lbl['compo.formation.nb.wagon.stack']}" />
							</f:facet>

							<h:inputText id="nbWagonsStack" value="#{rail.nbWagonsStack}"
								size="4" maxlength="2" onkeypress="return checkInteger(this);"
								onblur="checkIntegerNotNull(this)" />
						</rich:column>

						<rich:column width="80px" style="text-align:center;">
							<f:facet name="header">
								<h:outputText value="#{lbl['compo.departure.lot']}" />
							</f:facet>
							<h:inputText id="numLot" value="#{rail.numlot}" size="4"
								maxlength="2" onkeypress="return checkInteger(this);"
								onblur="checkIntegerNotNull(this)" />
						</rich:column>

						<!-- Colonne pour les indicateurs. -->
						<rich:column width="35px">
							<f:facet name="header">
								<h:outputText value="#{lbl['common.fault.indicator']}" />
							</f:facet>
							<h:graphicImage value="../../imgs/icons/ico_error_20x20.png"
								rendered="#{rail.errorIndicator}" />
							<h:graphicImage value="../../imgs/icons/ico_info_20x20.png"
								rendered="#{!rail.errorIndicator}" />
						</rich:column>

						<!-- Colonne de message -->
						<rich:column width="645px" style="text-align:left;">
							<f:facet name="header">
								<h:outputText value="#{lbl['common.message']}" />
							</f:facet>
							<h:outputText value="#{rail.errorMessage}" />
						</rich:column>
					</rich:extendedDataTable>
				</a4j:outputPanel>

				<!-- Le panneau pour les boutons. -->
				<h:panelGrid columns="2" id="formation_plan_1_command_panel"
					columnClasses="_left,_right" style="width:100%">
					<a4j:commandButton value="#{lbl['common.button.cancel']}"
						action="#{hubManaged.refreshHub}">
						<a4j:param name="fromOutcome" value="departure_success"
							assignTo="#{hubManaged.criterion.fromOutCome}" />
					</a4j:commandButton>

					<a4j:commandButton value="#{lbl['common.button.validate']}"
						render="formation_plan_panel"
						action="#{hubManaged.getFormationPlanPhaseTwo}" />
				</h:panelGrid>
			</h:panelGrid>
		</h:form>
	</ui:define>
</ui:composition>
</html>